package cn.fbs.controller;

import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.time.LocalDateTime;


@Component
public class SchedulController {

    @Autowired
    private RestTemplate restTemplate;

//    @Scheduled(fixedDelay = 30000)
    public void insertImage() {
        String jsonStr="{\"categoryIds\":[3534],\"fileName\":\"0_英国_20210226_航行_上_ee_dd_0001010003.jpg\",\"isProduct\":\"0\",\"memo\":\"\",\"taskName\":\"\",\"operator\":\"admin\",\"platformId\":\"\",\"sensorId\":\"\",\"shotDate\":\"\",\"source\":\"其他\",\"targetType\":\"012400300000000001\",\"realFileUrl\":\"/data/upload/img/1632712325148/0_英国_20210226_航行_上_ee_dd_0001010003.jpg\",\"zzdx\":\"蒙古军队装备\",\"uploadFileName\":\"0_英国_20210226_航行_上_ee_dd_0001010003.jpg\",\"expertMemo\":\"\",\"examineType\":2,\"finalCheck\":1,\"bdnm\":\"03\",\"wqzbbh\":\"033\"}";

        System.out.println(LocalDateTime.now());
        JSONObject jsonObject = new JSONObject();
        HttpHeaders headers = new HttpHeaders();
        headers.add("sessionId","eyJwYXNzd29yZCI6InpOekpMZlVoTkRBV3l0NzM0dXcwOHl3ME9rTXNILzlvc3Z0cVdIRWRBRzg9IiwibG9naW5OYW1lIjoiYWRtaW4iLCJ1c2VyTmFtZSI6IueuoeeQhuWRmCIsInVzZXJSb2xlIjoiMSIsInVzZXJJZCI6MzE4NTZ9");
        HttpEntity<String> requestEntity = new HttpEntity(jsonObject, headers);
        Object result = restTemplate.postForObject("http://localhost:9080/imageData/addZCImage", requestEntity, Object.class);


    }

    @Test
    public void test(){
        String jsonStr="{\"categoryIds\":[3534],\"fileName\":\"0_英国_20210226_航行_上_ee_dd_0001010003.jpg\",\"isProduct\":\"0\",\"memo\":\"\",\"taskName\":\"\",\"operator\":\"admin\",\"platformId\":\"\",\"sensorId\":\"\",\"shotDate\":\"\",\"source\":\"其他\",\"targetType\":\"012400300000000001\",\"realFileUrl\":\"/data/upload/img/1632712325148/0_英国_20210226_航行_上_ee_dd_0001010003.jpg\",\"zzdx\":\"蒙古军队装备\",\"uploadFileName\":\"0_英国_20210226_航行_上_ee_dd_0001010003.jpg\",\"expertMemo\":\"\",\"examineType\":2,\"finalCheck\":1,\"bdnm\":\"03\",\"wqzbbh\":\"033\"}";

        System.out.println(LocalDateTime.now());
        JSONObject jsonObject = new JSONObject();
        HttpHeaders headers = new HttpHeaders();
        headers.add("user","dfd");
        HttpEntity<String> requestEntity = new HttpEntity(jsonObject, headers);
        Object result = restTemplate.postForObject("http://localhost:9080/imageData/addZCImage", requestEntity, Object.class);


    }

}

